#pragma once
#include <pthread.h>
#include <cstdio>
#include <vector>
#include <unistd.h>
#include <string>
#include <iostream>
#include <pthread.h>

class Mutex {
public:
  Mutex(pthread_mutex_t *lock)
  : mutex_(lock) {}


  void lock() {
    pthread_mutex_lock(mutex_);
  }

  void unlock() {
    pthread_mutex_unlock(mutex_);
  }

private:
  pthread_mutex_t* mutex_;
};

class LockGuard{
public:
    LockGuard(pthread_mutex_t *mutex)
    : mutex_(mutex) 
    {
        mutex_.lock();   // 加锁
    }

    ~LockGuard() 
    {
        mutex_.unlock(); // 解锁
    }
private:
    Mutex mutex_;
};